package com.wealth.scsj.b_app.view.fragment.fourmodel;


import android.content.ContentResolver;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.vondear.rxtools.RxPermissionsTool;
import com.vondear.rxtools.RxPhotoTool;
import com.vondear.rxtools.RxSPTool;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.customview.dialog.ActionSheetDialog;
import com.wealth.scsj.b_app.utils.CropCircleTransformation;
import com.wealth.scsj.b_app.utils.SkipUtils;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;
import com.yalantis.ucrop.UCrop;
import com.yalantis.ucrop.UCropActivity;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import static android.app.Activity.RESULT_OK;


/**
 * 我的
 */
public class MineFragment extends BaseFragment implements View.OnClickListener{
    private View view;
    private ImageView mSettingIv;
    private RelativeLayout mMsgIv;
    private ImageView mHeadIv;
    /**
     * 未登录
     */
    private TextView mNicknameTv;
    private LinearLayout mLoginLl;
    private RelativeLayout mMineBackground;
    private ImageView mMineAdIv;
    private ImageView mBusinessStateIv;
    private ImageView mBillDetailsNextIv;
    /**
     * 营业中
     */
    private TextView mPayTypeNameTv;
    private RelativeLayout mBusinessStateRl;
    private ImageView mShopSettingIv;
    private ImageView mShopSettingNextIcon;
    private RelativeLayout mShopSettingRl;
    private ImageView mFinancialReconceIv;
    private ImageView mFinancialReconceNextIcon;
    private RelativeLayout mFinancialReconceRl;
    private ImageView mExtensionCodeIv;
    private ImageView mExtensionCodeNextIcon;
    private RelativeLayout mExpandCodeRl;
    private ScrollView mScrollView;

    private Uri resultUri;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_mine, null);

        initView(inflate, null);
        initListener();
        initData();
        return inflate;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        mSettingIv =  view.findViewById(R.id.setting_iv);
        mMsgIv =  view.findViewById(R.id.msg_iv);
        mHeadIv =  view.findViewById(R.id.head_iv);
        mNicknameTv =  view.findViewById(R.id.nickname_tv);
        mLoginLl =  view.findViewById(R.id.login_ll);
        mMineBackground = view.findViewById(R.id.mine_background);
        mMineAdIv =  view.findViewById(R.id.mine_ad_iv);
        mBusinessStateIv =  view.findViewById(R.id.business_state_iv);
        mBillDetailsNextIv =  view.findViewById(R.id.bill_details_next_iv);
        mPayTypeNameTv =  view.findViewById(R.id.pay_type_name_tv);
        mBusinessStateRl =  view.findViewById(R.id.business_state_rl);
        mShopSettingIv =  view.findViewById(R.id.shop_setting_iv);
        mShopSettingNextIcon =  view.findViewById(R.id.shop_setting_next_icon);
        mShopSettingRl =  view.findViewById(R.id.shop_setting_rl);
        mFinancialReconceIv =  view.findViewById(R.id.financial_reconce_iv);
        mFinancialReconceNextIcon =  view.findViewById(R.id.financial_reconce_next_icon);
        mFinancialReconceRl =  view.findViewById(R.id.financial_reconce_rl);
        mExtensionCodeIv =  view.findViewById(R.id.extension_code_iv);
        mExtensionCodeNextIcon =  view.findViewById(R.id.extension_code_next_icon);
        mExpandCodeRl =  view.findViewById(R.id.expand_code_rl);
        mScrollView = view.findViewById(R.id.scroll_view);
    }

    @Override
    protected void initListener() {
        mSettingIv.setOnClickListener(this);
        mMsgIv.setOnClickListener(this);
        mHeadIv.setOnClickListener(this);
        mMineAdIv.setOnClickListener(this);
        mBusinessStateRl.setOnClickListener(this);
        mShopSettingRl.setOnClickListener(this);
        mFinancialReconceRl.setOnClickListener(this);
        mExpandCodeRl.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        Resources r = this.getResources();
        resultUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
                + r.getResourcePackageName(R.drawable.ic_launcher_background) + "/"
                + r.getResourceTypeName(R.drawable.ic_launcher_background) + "/"
                + r.getResourceEntryName(R.drawable.ic_launcher_background));
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.setting_iv:
                SkipUtils.toSetting(getHoldingActivity());
                break;
            case R.id.msg_iv:
                break;
            case R.id.head_iv:

                break;
            case R.id.mine_ad_iv:
                break;
            case R.id.business_state_rl:
                SkipUtils.toBusinessStatePage(getHoldingActivity());
                break;
            case R.id.shop_setting_rl:
                SkipUtils.toStoreSettingPage(getHoldingActivity());
                break;
            case R.id.financial_reconce_rl:
                SkipUtils.toMoney(getHoldingActivity());
                break;
            case R.id.expand_code_rl:
                //TODO 暂时跳转商家注册页面
                SkipUtils.toRegisterZeroStep(getHoldingActivity());
                break;
        }
    }
}
